package com.ruoyi.energy.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.energy.domain.QyOperationStatistics;
import com.ruoyi.energy.service.IQyOperationStatisticsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 运营统计Controller
 *
 * @author cjie
 * @date 2021-08-02
 */
@Api(tags = " 运营统计")
@RestController
@RequestMapping("/qyOperationStatistics")
public class QyOperationStatisticsController extends BaseController {
    @Autowired
    private IQyOperationStatisticsService qyOperationStatisticsService;

    /**
     * 查询运营统计列表
     */
    @ApiOperation(value="查询运营统计列表", notes="查询运营统计列表")
    @PreAuthorize(hasPermi = "energy:qyOperationStatistics:list")
    @GetMapping("/list")
    public TableDataInfo list(QyOperationStatistics qyOperationStatistics) {
        startPage();
        List<QyOperationStatistics> list = qyOperationStatisticsService.selectQyOperationStatisticsList(qyOperationStatistics);
        return getDataTable(list);
    }

    /**
     * 导出运营统计列表
     */
    @ApiOperation(value="导出运营统计列表", notes="导出运营统计列表")
    @PreAuthorize(hasPermi = "energy:qyOperationStatistics:export")
    @Log(title = "运营统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QyOperationStatistics qyOperationStatistics) throws IOException {
        List<QyOperationStatistics> list = qyOperationStatisticsService.selectQyOperationStatisticsList(qyOperationStatistics);
        ExcelUtil<QyOperationStatistics> util = new ExcelUtil<QyOperationStatistics>(QyOperationStatistics.class);
        util.exportExcel(response, list, "运营统计数据");
    }
    /**
     * 获取运营统计详细信息
     */
    @ApiOperation(value="获取运营统计详细信息", notes="获取运营统计详细信息")
    @PreAuthorize(hasPermi = "energy:qyOperationStatistics:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(qyOperationStatisticsService.selectQyOperationStatisticsById(id));
    }

    /**
     * 新增运营统计
     */
    @ApiOperation(value="新增运营统计", notes="新增运营统计")
    @PreAuthorize(hasPermi = "energy:qyOperationStatistics:add")
    @Log(title = "运营统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QyOperationStatistics qyOperationStatistics) {
        return toAjax(qyOperationStatisticsService.insertQyOperationStatistics(qyOperationStatistics));
    }

    /**
     * 修改运营统计
     */
    @ApiOperation(value="修改运营统计", notes="修改运营统计")
    @PreAuthorize(hasPermi = "energy:qyOperationStatistics:edit")
    @Log(title = "运营统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QyOperationStatistics qyOperationStatistics) {
        return toAjax(qyOperationStatisticsService.updateQyOperationStatistics(qyOperationStatistics));
    }

    /**
     * 删除运营统计
     */
    @ApiOperation(value="删除运营统计", notes="删除运营统计")
    @ApiImplicitParam(name = "ids", value = "运营统计ID数组", required = true,paramType = "path", allowMultiple=true, dataType = "String")
    @PreAuthorize(hasPermi = "energy:qyOperationStatistics:remove")
    @Log(title = "运营统计", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(qyOperationStatisticsService.deleteQyOperationStatisticsByIds(ids));
    }
}
